import 'core-js/es6/promise';
import Vue from 'vue';
import axios from 'axios';
import '@/module/common';
import { mytips } from '@/module/tools';

Vue.config.productionTip = false;

new Vue({
    el: '#app',
    data: {
        checkImg: API_PATH + '/generateImageCode',
    },
    methods: {
        login(){
            let account = this.$refs.account.value;
            let password = this.$refs.password.value;

            if(! account){
                mytips('账号不能为空');
                return false;
            }
            if(! password){
                mytips('密码不能为空');
                return false;
            }

            axios.post(API_PATH + '/login', {
                username: account,
                password: password,
            }).then(
                res => {
                    if(res.data.code == 0){
                        location.href = 'center.html';
                    }
                }
            );
        },
        renewCheckImg(){
            this.checkImg = API_PATH + '/generateImageCode?' + Math.random();
        }
    },
});
